home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 4
/
CU Amiga Magazine's Super CD-ROM 04 (1996)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1996-11].iso
/
magazine
/
psion
/
misc
/
ml3.lzx
/
ml3.opl
Wrap
Text File
|
1993-01-22
|
8KB
|
294 lines
proc ML3:
global prompt$(20),prompt& REM Vars
local g% REM More vars
if not exist ("M:\Miles") REM Change "M" to A or B if you want
create "M:\Miles",a,time$,startpo$,startmi&,endpos$,endmile&,totb&,totp&
else
open "M:\Miles",a,time$,startpo$,startmi&,endpos$,endmile&,totb&,totp&
endif
last
gat 0,0
gfill 240,14,2
gat 4,10
gtmode 1
gstyle 1 REM Setting up top line of window
gprint "ML3 - Mileage logging for the Series 3"
gcreate(0,16,240,64,1) REM Create a window for the rest
do REM Get in the loop
gat 0,16
gstyle 9
prompt$=upper$(A.endpos$) REM Get Last location from the file
gprintb "LAST LOCATION WAS "+prompt$,240,2 REM Show the above
gat 0,34
prompt&=A.endmile& REM get last mileage
gprintb "LAST MILEAGE LOGGED WAS "+gen$(prompt&,10)+" MILES",240,2
gat 0,38
glineby 240,0 REM Make the screen look good with graphics
gat 0,39
glineby 240,0 REM Make the above line 'thick'
gat 0,51
gstyle 1 REM Setup prompts for user
gprintb "[ENTER] to log a trip",240,2
gat 0,62 REM another prompt
gprintb "[HELP] or [MENU] for other options",240,2
g%=get REM Get keystrokes
if g%=13 REM Enter?
log:
endif
if g%=291 REM Help?
help:
endif
if g%=290 REM Menu key?
domenu:
endif
if kmod and 8 REM Psion key?
dopsion:(g%-512)
endif
until g%=27 REM Esc key ALSO exits
endp
proc log: REM This is where we write trip details to file
local d%,pick%,place$(30),mile&,lastloc$(30),lastmil&
last REM Make sure we're at the end of the file
dinit "Log A Trip"
dposition 0,1 REM Set up Trip Dialog Box
dtext "","úLast location was "+ A.endpos$
lastloc$=A.endpos$ REM Convert some vars
dedit place$,"New location is"
prompt$=place$ REM Need this to refresh main window text
dtext "","úLast mileage was "+fix$( A.endmile&,0,10)
lastmil&=A.endmile&
dlong mile&,"New mileage is", A.endmile&+1,10000000
mile&=prompt& REM also need this to refresh mileage shown on main window
dchoice pick%,"Kind of trip","Business,Personal"
dialog
if pick%=1 REM Business Trip
A.totb&=mile&-lastmil& REM Assign inputs to file
A.totp&=0
elseif pick%=2 REM Personal trip
A.totp&=mile&-lastmil& REM Assign inputs to file
A.totb&=0 REM Just in case
elseif pick%=0 REM They didn't want to record trip
return REM so get outta here
endif
A.time$=mid$(Datim$,5,17) REM Put date&time into record
A.startpo$=upper$(lastloc$) REM Juggling!
A.startmi&=lastmil& REM Juggling!
A.endpos$=upper$(place$) REM More juggling!
A.endmile&=mile&
append REM Write trip details to file
return
endp
proc totals:
local pick%,busmil&,persmil&
busmil&=0
first
do
busmil&=busmil&+(A.totb&)
next
until eof
persmil&=0
first
do
persmil&=persmil&+(A.totp&)
next
until eof
dinit
dtext "","TOTAL MILES RECORDED",$302
dtext "","Total Business Miles Are "+gen$(busmil&,10)+" miles."
dtext "","Total Personal Miles Are "+gen$(persmil&,10)+" miles."
dtext "","Total Combined Miles Are "+gen$(busmil&+persmil&,10)+" miles."
dialog
last REM go to last record
prompt$=upper$(A.endpos$)
prompt&=A.endmile&
endp
proc domenu:
local m%,m$(1)
minit
mcard "Mlog","About",%a,"Export",%e,"Totals",%t,"Setup",%s,"Quit",%x
m%=menu
if m%=97 REM About?
about:
elseif m%=101 REM Export?
export:
elseif m%=116 REM Totals?
totals:
elseif m%=115 REM Setup?
setup:
elseif m%=120 REM Quit?
stop
endif
endp
proc dopsion:(kv%)
local choice%
choice%=kv%
if choice%=97 REM About selected?
about:
elseif choice%=101 REM Export File?
export:
elseif choice%=116 REM Totals?
totals:
elseif choice%=115 REM Setup?
setup:
elseif choice%=120 REM Quit?
stop
endif
endp
proc about:
dinit
dtext "","ML3 vers 1.0",$102
dtext "","¸1993 Les Hall",$102
dtext "","CIS 71053,1676",$102
dtext "",chr$(34)+"pax vobiscum"+chr$(34),$101
dialog
endp
proc setup:
local choice%,firsloc$(20),firsmil&
beep 1,400 :beep 1,200 :beep 1,400 :beep 1,200
dinit
dtext "","ML3 SETUP - WARNING!",$302
dtext "","You are about to erase or create a",2
dtext "","Mlog.ODB File. Are you sure? Go back press",2
dtext "","[Help] then select þSetup if unsure.",2
dbuttons "Not Sure",-27,"Positive",13
choice%=dialog
if choice%=13
close
delete ("M:\Miles.odb")
create "M:\Miles",A,time$,startpo$,startmi&,endpos$,endmile&,totb&,totp&
dinit
dtext "","Enter Initial Location & Mileage",$302
firsloc$="Home/Work etc"
dedit firsloc$,"Enter Initial Location:"
dlong firsmil&,"Enter Initial Mileage :",1,10000000
dialog
A.startpo$="Start of ML3 File"
A.endpos$=firsloc$
A.endmile&=firsmil&
A.time$=mid$(datim$,5,17)
append
endif
endp
proc export:
local busmil&,persmil&
lopen "M:\WRD\milelog.wrd"
busy "Saving Milelog.WRD",3
lprint "MILEAGE LOG EXPORTED ON "+DATIM$
lprint chr$(13)
lprint "This is a tab delimited file. Please set up six tabs to view properly"
lprint "The list below shows what each tab/column represents"
lprint "DATE&TIME START LOC' START MILES END LOC' END MILES BUS' MILES PER' MILES"
lprint chr$(13)
first
while not eof
lprint A.time$+chr$(9)+A.startpo$+chr$(9),A.startmi&,chr$(9)+A.endpos$+chr$(9),A.endmile&,chr$(9),A.totb&,chr$(9),A.totp&
next
endwh
busmil&=0
first
do
busmil&=busmil&+(A.totb&)
next
until eof
lprint chr$(13)
lprint "Total Business Miles Are ";busmil&;" Miles"
persmil&=0
first
do
persmil&=persmil&+(A.totp&)
next
until eof
lprint "Total Personal Miles Are ";persmil&;" Miles"
busmil&=0
persmil&=0
first
do
busmil&=busmil&+(A.totb&)
next
until eof
first
do
persmil&=persmil&+(A.totp&)
next
until eof
lprint "Total Combined Miles Are ";busmil&+persmil&;" Miles"
lprint chr$(13)
lprint "********* END OF MILEAGE LOG *******"
lclose
last
busy off
endp
proc help:
local g%
top::
dinit
dtext ""," Help:ML3",$300
dtext "","þUsing ML3",$500
dtext "","þSetup",$500
dtext "","þExporting",$500
dtext "","þKudos, Thanks",$500
g%=dialog
if g%=0
return
elseif g%=291
return
elseif g%=2
dinit
dtext "","Help: Using ML3 - Run Setup First!",$300
dtext "","Press [Enter] to open the trip input",0
dtext "","dialog box. Enter your current",0
dtext "","location & then the current mileage. ",0
dtext "","Then choose wether it was a Business or",0
dtext "","a Personal trip. All this data is saved",0
dtext "","to Mlog.ODB on Internal memory.",0
dialog
goto top::
elseif g%=3
dinit
dtext "","Help: ML3 Setup",$300
dtext "","You must select Setup once before you can",0
dtext "","use ML3. Either select Setup from the ",0
dtext "","menu or use Psion-S. You are given the ",0
dtext "","chance to escape if selected by mistake!",0
dtext "","Otherwise input your initial location",0
dtext "","& mileage. Mlog.ODB is created on M:",0
dialog
goto top::
elseif g%=4
dinit
dtext "","Help: Exporting A Mileage Log",$300
dtext "","When you select Export from the menu or",0
dtext "","Psion-E from the keyboard, you export a",0
dtext "","tab-delimited file (Miles.WRD) to your",0
dtext "","WRD directory on your Internal memory.",0
dtext "","Print from there or export it to your",0
dtext "","Macintosh or PC. Try it out!",0
dialog
goto top::
elseif g%=5
dinit
dtext "","Help: Kudos, Thanks",$300
dtext "","First, thanks to Psion Inc & Psion PLC",0
dtext "","for making such cool little gizmos.",0
dtext "","Thanks also to all the members of the",0
dtext "","Palmtop Forum who have shared their",0
dtext "","ideas & code with their fellow users.",0
dtext "","Special thanks to Jim, Mark & Rowan.",0
dialog
goto top::
endif
ENDP